{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <fieldset id="searchFieldset_currentTableRenderId" class="table-search-fieldset">
                        <legend>条件搜索</legend>
                        <form class="layui-form layui-form-pane form-search">
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">ID|订单号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="ordersn" placeholder="ID|订单号"
                                        value="{:input('get.ordersn')}" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">商家</label>
                                <div class="layui-input-inline">
                                    <select name="businessid" lay-filter="businessid" lay-search>
                                        <option value="">请选择搜索商家</option>
                                        {foreach $shop as $v}
                                        <option value="{$v.id}" {if !empty(input('get.businessid')) &&
                                            input('get.businessid')==$v.id}selected{/if}>{$v.title}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                    <label class="layui-form-label">省份</label>
                                    <div class="layui-input-inline">
                                        <select name="province" lay-filter="province">
                                            <option value="">请选择搜索管理省份</option>
                                            {foreach $province as $v}
                                            <option value="{$v.area_code}" {if !empty(input('get.province')) &&
                                                input('get.province')==$v.area_code}selected{/if}>{$v.name}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-inline">
                                    <label class="layui-form-label">城市</label>
                                    <div class="layui-input-inline">
                                        <select name="city" lay-filter="city">
                                            <option value="">请选择搜索管理城市</option>
                                            {foreach $city as $v}
                                            <option value="{$v.area_code}" {if !empty(input('get.city')) &&
                                                input('get.city')==$v.area_code}selected{/if}>{$v.name}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-inline">
                                    <label class="layui-form-label">区域</label>
                                    <div class="layui-input-inline">
                                        <select name="area" lay-filter="area">
                                            <option value="">请选择搜索管理区域</option>
                                            {foreach $area as $v}
                                            <option value="{$v.area_code}" {if !empty(input('get.area')) &&
                                                input('get.area')==$v.area_code}selected{/if}>{$v.name}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-inline">
                                    <label class="layui-form-label">街道</label>
                                    <div class="layui-input-inline">
                                        <select name="street" lay-filter="street">
                                            <option value="">请选择搜索管理街道</option>
                                            {foreach $street as $v}
                                            <option value="{$v.id}" {if !empty(input('get.street')) &&
                                                input('get.street')==$v.id}selected{/if}>{$v.name}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                            <div class="layui-form-item layui-inline">
                                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="sreach">搜索</button>
                            </div>
                        </form>
                    </fieldset>
                </div>
                <div class="layui-card-header">
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th>
                                    <div class="layui-table-cell">订单ID</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">订单类型</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">订单编号</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">商家</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">商品信息</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">服务人员信息</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">收货信息</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">预约时间</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">用户备注</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">优惠券减免</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">折扣减免</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">其它减免</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">原价/支付价</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">订单状态</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">时间</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">操作</div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>
                                    <div class="layui-table-cell">{$v.id|default=''}</div>
                                </td>
                                <td>
                                    {if $v.type == 1}
                                    <a title="技术服务" href="javascript:;" class="layui-bg-cyan layui-btn layui-btn-sm">
                                        技术服务
                                    </a>
                                    {/if}
                                    {if $v.type == 2}
                                    <a title="配送服务" href="javascript:;" class="layui-bg-cyan layui-btn layui-btn-sm">
                                        配送服务
                                    </a>
                                    {/if}
                                    {if $v.type == 3}
                                    <a title="商品服务" href="javascript:;" class="layui-bg-cyan layui-btn layui-btn-sm">
                                        商品服务
                                    </a>
                                    {/if}
                                    {if $v.type == 4}
                                    <a title="商品服务" href="javascript:;" class="layui-bg-cyan layui-btn layui-btn-sm">
                                        特产服务
                                    </a>
                                    {/if}
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.ordersn|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.business|default=''}</div>
                                </td>
                                <td>
                                    {foreach $v.good as $good}
                                    <div id="layer-photos-demo" class="layer-photos-demo">
                                        <img layer-pid="" style="height: 40px;" layer-src="{$good.images[0]|default=''}"
                                            src="{$good.images[0]|default=''}" alt="{$good.images[0]|default=''}">
                                    </div>
                                    <div class="layui-table-cell">{$good.title|default=''}(规格:{$good.name|default=''})
                                        {$good.price|default='0'}元
                                        X{$good.number|default='0'}</div>
                                    {/foreach}
                                </td>
                                <td>
                                    {if $v.putorder == 0}
                                    <div class="layui-table-cell">--</div>
                                    {else}
                                    姓名:{$v.people.name|default='无'}<br />
                                    技工账号:{$v.people.mobile|default='无'}
                                    {/if}
                                </td>
                                <td>
                                    联系人:{$v.name}<br />
                                    联系电话:{$v.mobile}<br />
                                    地址:{$v.province_name|default=''}{$v.city_name|default=''}{$v.area_name|default=''}{$v.street_name|default=''}{$v.getaddress|default=''}{$v.address|default=''}
                                </td>
                                <td>{$v.times}<br />
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.remark|default='无'}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.coupontotal|default='0'}元</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.zhekoutotal|default='0'}元</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.othertotal|default='0'}元</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.ptotal|default='0'}元/{$v.total|default='0'}元</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.status_name|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">
                                        创建时间:{$v.created|default='无'}
                                    </div>
                                    <div class="layui-table-cell">
                                        支付时间:{$v.paytimes|default='无'}
                                    </div>
                                    <div class="layui-table-cell">
                                        接单|配送时间:{$v.fwtimes|default='无'}
                                    </div>
                                    <div class="layui-table-cell">
                                        完成时间:{$v.finishtimes|default='无'}
                                    </div>
                                    <div class="layui-table-cell">
                                        取消时间:{$v.caceltimes|default='无'}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">
                                        <a title="产品清单"
                                            onclick="open_add('产品清单','/order/orderdetail?ordersn={$v.ordersn}')"
                                            href="javascript:;" class="layui-btn layui-btn-sm">
                                            产品清单
                                        </a>
                                        <a title="确认取消用户待支付订单?"
                                            onclick="open_status(this,'/order/order_str','{$v.id}',5)"
                                            href="javascript:;" class="layui-btn-danger layui-btn layui-btn-sm">
                                            取消订单
                                        </a>
                                        {if $v.type == 1 || $v.type == 2 || $v.type == 3}
                                        <a title="更改或指派给师傅"
                                            onclick="promt_alert('请填写当前订单商户下师傅账号','/order/order_send','{$v.id}')"
                                            href="javascript:;" class="layui-btn-normal layui-btn layui-btn-sm">
                                            {if $v.putorder == 0}
                                            更改或指派给师傅
                                            {else}
                                            更改师傅
                                            {/if}
                                        </a>
                                        {else}
                                        <a title="发货信息" onclick="open_alert('填写订单发货信息','/order/order_send','{$v.id}')"
                                            href="javascript:;" class="layui-btn-normal layui-btn layui-btn-sm">
                                            更改发货信息
                                        </a>
                                        {/if}
                                        <a title="确定完成订单?" onclick="open_status(this,'/order/order_str','{$v.id}',4)"
                                            href="javascript:;" class="layui-btn layui-btn-sm">
                                            完成订单
                                        </a>
                                    </div>
                                </td>
                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
{include file="public/footer"}
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;
        //监听省份选择
        form.on('select(province)', function (data) {
            if (!data.value) {
                $('select[name="city"]').html('');
                $('select[name="area"]').html('');
                $('select[name="street"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getregion',
                data: { area_code: data.value, level: 2 },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择城市</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.area_code;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="city"]').html(str);
                        $('select[name="area"]').html('');
                        $('select[name="street"]').html('');
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
        //监听城市选择
        form.on('select(city)', function (data) {
            if (!data.value) {
                $('select[name="area"]').html('');
                $('select[name="street"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getregion',
                data: { area_code: data.value, level: 3 },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择区域</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.area_code;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="area"]').html(str);
                        $('select[name="street"]').html('');
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
        //监听区域选择
        form.on('select(area)', function (data) {
            if (!data.value) {
                $('select[name="street"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getregion',
                data: { area_code: data.value, level: 4 },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择街道</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.id;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="street"]').html(str);
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
    });
</script>
</body>